class Solution:
    def reverseWords(self, s: str) -> str:
        s_split = s.strip().split(" ")
        return " ".join(reversed(s_split))


if __name__ == '__main__':
    s = Solution().reverseWords("  world! hello  ")
    print(s)